package com.sky.controller.admin.user;

import com.sky.constant.ShopStatusConstant;
import com.sky.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.*;

@RestController(value = "userShopController")
@RequestMapping("/user/shop")
public class ShopController {

    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    /**
     * 获取营业状态
     *
     * @return {@link Result}
     */
    @GetMapping("/status")
    public Result queryStatus(){
        ValueOperations<String, Object> valueOperations = redisTemplate.opsForValue();
        //获取营业的状态
        Integer status = (Integer) valueOperations.get(ShopStatusConstant.SHOP_STATUS);
        return Result.success(status == null ? 0 : status);
    }
}
